<%-- 
    Document   : invitations
    Created on : 5 oct. 2011, 10:57:45
    Author     : Antonin Mozzati & Yanick Schürter
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Tweetor : invitations!</title>
        <LINK rel=stylesheet type="text/css" href="style.css">
        <LINK rel=stylesheet type="text/css" href="menu.css">
    </head>

    <body>
        <div id="main">
            <div id="header">

                <!-- Login -->
                <jsp:include page="header/login.jsp"/>
                <jsp:include page="header/logo.jsp"/>
                <jsp:include page="header/menu.jsp"/>

            </div> <!-- header -->

            <c:set var="invitations" value="${listeInvitations.getByUser(sessionScope.sessionID)}" />
            <c:choose>
                <c:when test="${empty invitations}">
                    Vous n'avez aucune invitation actuellement
                </c:when>
                <c:otherwise>
                    <%-- Liste des invitations adressées à l'utilisateur --%>
                    <table id="tableFlux" style="border-width: medium; text-align: center;">
                        <tr>
                            <th>Flux</th>
                            <th>Auteur</th>
                            <th>Droit de poster</th>
                            <th>Répondre</th>
                        </tr>
                        <c:forEach var="invitation" items="${invitations}">
                            <c:set var="flux" value="${listeFlux.getById(invitation.id_flux)}" />
                            <tr>
                                <td><c:out value="${flux.getTitreFlux()}" /></td>
                                <td><c:out value="${listeUtilisateur.getByID(flux.id_utilisateur).getLogin()}" /></td>
                                <td>
                                    <c:choose>
                                        <c:when test="${invitation.peutPoster == 1}">
                                            Oui
                                        </c:when>
                                        <c:otherwise>
                                            Non
                                        </c:otherwise>
                                    </c:choose>
                                </td>
                                <td>
                                    <form action="invitations.do" method="POST">
                                        <input type="hidden" name="id_invitation" value="<c:out value="${invitation.id_invitation}" />" />
                                        <input type="submit" name="reponseSubmit" value="Accepter" />
                                        <input type="submit" name="reponseSubmit" value="Refuser" />
                                    </form>
                                </td>
                            </tr>
                        </c:forEach>
                    </table>
                </c:otherwise>
            </c:choose>
        </div> <!-- main -->

    </body>
</html>
